﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClassLearn
{
    class Program
    {
        static void Main(string[] args)
        {
            myclasscar mycar = new myclasscar(9,"Gen");
            //mycar._name = "Electric";
            //mycar._speed = 9;
            Console.WriteLine("{0} - {1}",mycar._name.ToString(), mycar._speed);
            
        }
    }
    public class myclasscar : cars
    {
        public myclasscar(int _speed, string _name)
            : base(_speed, _name)
        // Invoke the derived class
        {
            _speed = 40;
            _name = "General";
            Console.WriteLine("In the derived class constructor.");
        }
        public myclasscar()
            : base()
        {
            Console.WriteLine("in derived class parameterless constructor");
            _speed = _speed * 10;
            _name = "general " + _name;
        }
    }
    public class cars {
        public int _speed;
        public string _name;
        public cars() {
            Console.WriteLine("In the base class parameter less constructor");
        }
        public cars(int speed, string name)
        {
            Console.WriteLine("In the base class constructor");
            if (speed < 10)
            {
                speed = 10;
            }
            _speed = speed;
            _name = name;
        }
    }
}
